/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package network;

import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author anh_yeu_em_nhieu_lam
 */
public class ReadFileFromWeb {

    public ReadFileFromWeb() {
        InputStream input = null;
        try {
            URI uri = new URI("http://localhost/www/PhpWebService/test.html");
            URL url = uri.toURL();
            input = url.openStream();
            String tu = "";
            int ch;
            while ((ch = input.read()) != -1) {
                tu += String.valueOf((char) ch);
            }
            System.out.print(tu);
        } catch (IOException ex) {
            Logger.getLogger(ReadFileFromWeb.class.getName()).log(Level.SEVERE, null, ex);
        } catch (URISyntaxException ex) {
            Logger.getLogger(ReadFileFromWeb.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            try {
                input.close();
            } catch (IOException ex) {
                Logger.getLogger(ReadFileFromWeb.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    /*
    public static void main(String arg[]){
    new ReadFileFromWeb();
    }*/
}
